<?php
/**
 * Created by Yevgen Vershynin.
 * User: Yevgen Vershynin
 * Description: Describes Employee. Creation and validation of Employee object.
 */
class EmployeeObject
{
    public $employeeNumber = "";
    public $lastName = "";
    public $firstName = "";
    public $extension = "";
    public $email = "";
    public $office = "";
    public $reportsTo = "";
    public $jobTitle = "";

    public function __construct($dbData)
    {
        //Validate input data and save it to object properties
        if(isset($dbData['employeeNumber'])) {
            $this->employeeNumber = $dbData['employeeNumber'];
        }
        if(isset($dbData['lastName'])) {
            $this->lastName = $dbData['lastName'];
        }
        if(isset($dbData['firstName'])) {
            $this->firstName = $dbData['firstName'];
        }
        if(isset($dbData['extension'])) {
            $this->extension = $dbData['extension'];
        }
        if(isset($dbData['email'])) {
            $this->email = $dbData['email'];
        }
        if(isset($dbData['reportsTo'])) {
            $emlModel = new EmployeeModel();
            $this->reportsTo = $emlModel->getEmployeeById($dbData['reportsTo']);
        }
        if(isset($dbData['jobTitle'])) {
            $this->jobTitle = $dbData['jobTitle'];
        }
        if(isset($dbData['officeCode'])) {
            $officeModel = new OfficeModel();
            $this->office = $officeModel->getOfficeById($dbData['officeCode']);
        }

    }
}
